home *** CD-ROM | disk | FTP | other *** search
/ PC for Alla 2005 April / PC för Alla 0504.iso / noje / arcade-3.6.exe / tetris.swf / scripts / frame_25 / DoAction.as
Encoding:
Text File  |  2003-11-29  |  2.1 KB  |  88 lines

  1. stop();
  2. showScores = function()
  3. {
  4.    var i = 10;
  5.    while(i > 0)
  6.    {
  7.       var n = scoreboard_lv["name" + (page + i)];
  8.       var s = scoreboard_lv["score" + (page + i)];
  9.       var l_mc = this["line" + i + "_mc"];
  10.       l_mc.rank_txt.text = page + i + ".";
  11.       l_mc.name_txt.text = !n.length ? "-" : n.toLowerCase();
  12.       l_mc.score_txt.text = !s.length ? "-" : s.addCommas();
  13.       l_mc.rank_txt.textColor = l_mc.name_txt.textColor = l_mc.score_txt.textColor = !(game_so.data.playerName.length && n.toLowerCase() == game_so.data.playerName.toLowerCase()) ? 7833770 : 16777215;
  14.       l_mc._visible = true;
  15.       loading_mc._visible = false;
  16.       i--;
  17.    }
  18. };
  19. page = 0;
  20. maxScore = 100;
  21. scoreboard_lv = new LoadVars();
  22. if(score > 0 && game_so.data.playerName.length > 0)
  23. {
  24.    scoreboard_lv.score = score;
  25.    scoreboard_lv.name = game_so.data.playerName.toLowerCase();
  26. }
  27. scoreboard_lv.game = "tetris";
  28. scoreboard_lv.sendAndLoad("http://score.openwares.org/games_score_text.php",scoreboard_lv,"POST");
  29. scoreboard_lv.onLoad = function(success)
  30. {
  31.    if(success)
  32.    {
  33.       if(Boolean(scoreboard_lv.success))
  34.       {
  35.          next_btn._visible = true;
  36.          if(scoreboard_lv.maxScore.length > 0)
  37.          {
  38.             maxScore = Number(scoreboard_lv.maxScore);
  39.          }
  40.          showScores();
  41.       }
  42.       else
  43.       {
  44.          loading_mc.errorMsg = scoreboard_lv.errorMsg.toLowerCase();
  45.          loading_mc.gotoAndStop(2);
  46.       }
  47.    }
  48.    else
  49.    {
  50.       loading_mc.errorMsg = "could not access scores.";
  51.       loading_mc.gotoAndStop(2);
  52.    }
  53. };
  54. score = 0;
  55. next_btn._visible = last_btn._visible = false;
  56. last_btn.onPress = function()
  57. {
  58.    page -= 10;
  59.    if(page < 0)
  60.    {
  61.       page = 0;
  62.    }
  63.    if(page < 10)
  64.    {
  65.       last_btn._visible = false;
  66.    }
  67.    next_btn._visible = true;
  68.    showScores();
  69. };
  70. next_btn.onPress = function()
  71. {
  72.    page += 10;
  73.    if(page > maxScore)
  74.    {
  75.       page = maxScore;
  76.    }
  77.    if(page > maxScore - 20)
  78.    {
  79.       next_btn._visible = false;
  80.    }
  81.    last_btn._visible = true;
  82.    showScores();
  83. };
  84. newGame_btn.onRelease = function()
  85. {
  86.    gotoAndStop(2);
  87. };
  88.